variables:
  - &buildx_plugin 'woodpeckerci/plugin-docker-buildx:latest'
  - &platforms 'linux/arm/v7,linux/arm64/v8,linux/amd64'
  - publish_logins: &publish_logins # Default DockerHub login
      - registry: https://index.docker.io/v1/
        username:
          from_secret: DOCKER_USERNAME
        password:
          from_secret: DOCKER_PASSWORD
  - path: &when_path
      # web source code
      - 'assets/**'
      # go source code
      - '**/*.go'
      - 'go.*'
      # Dockerfile changes
      - 'Dockerfile'
      # pipeline config changes
      - '.woodpecker/docker.yaml'

steps:
  release:
    image: *buildx_plugin
    settings:
      repo: vnpower/pixivfe
      dockerfile: Dockerfile
      platforms: *platforms
      logins: *publish_logins
      tag: [latest, '${CI_COMMIT_TAG}']
    when:
      - event: [ tag, release ]
        branch: [ v2 ]

  next:
    image: *buildx_plugin
    settings:
      repo: vnpower/pixivfe
      dockerfile: Dockerfile
      platforms: *platforms
      logins: *publish_logins
      tag: [next, 'next-${CI_COMMIT_SHA:0:10}']
    when:
      - event: [ push ]
        branch: [ v2 ]
        path: *when_path
